#include <iostream>

using namespace std;

typedef long long LL;

const int N = 2010;

int n = 2000;
char a[N], b[N];
LL c[N];

int main()
{
	int cnt = 1, ret = 0;
	cin >> a[1] >> b[1] >> c[1];
	for (int i = 2; i <= n; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
		if ((a[i] == b[i]) && (a[i - 1] == b[i - 1]) && (c[i] - c[i - 1] <= 1000))	cnt++;
		else
		{
			ret = max(ret, cnt);
			cnt = 1;
		}
	}

	cout << ret << endl;

	return 0;
}